package com.syx.friend.Controller.question;

import com.syx.commoncore.Model.Result;
import com.syx.commoncore.Model.TableDataInfoResult;
import com.syx.friend.Aop.CheckUserStatus;
import com.syx.friend.Model.question.DTO.QuestionQueryDTO;
import com.syx.friend.Model.question.VO.QuestionDetailVO;
import com.syx.friend.Model.question.VO.QuestionVO;
import com.syx.friend.Service.IQuestionService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/question")
public class QuestionController {
    @Resource
    IQuestionService iQuestionService;

    @GetMapping("/semiLogin/list")
    public TableDataInfoResult list(QuestionQueryDTO questionQueryDTO){

        return  iQuestionService.list(questionQueryDTO);

    }

    //获取题目详情内容，点击开始答题后的内容
    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId){
        return iQuestionService.detail(questionId);



    }
    //redis中查找，如果没有的话再查mysql
    @CheckUserStatus
    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long questionId){
        //返回上一题的题目Id
        return iQuestionService.preQuestion(questionId);


    }
    @CheckUserStatus
    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long questionId){
        //返回下一题的题目Id
        return iQuestionService.nextQuestion(questionId);



    }

    @GetMapping("/semiLogin/hotList")
    public Result<List<QuestionVO>> hotList(){
        return iQuestionService.hotList();
    }


}
